package com.ysd.servlet;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.Impl.LeansnewsDaoImpl;
import com.ysd.dao.Impl.NewsCatalogueDaoImpl;
import com.ysd.entity.Leansnews;
import com.ysd.entity.NewsCatalogue;

public class NewsServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//request.setCharacterEncoding("UTF-8");
		//调用实现类编写方法
		//新闻分类
		NewsCatalogueDaoImpl lDao = new NewsCatalogueDaoImpl();
		List<NewsCatalogue> leanslist=lDao.getNewsList();
		request.setAttribute("leanslist", leanslist);
		
		//通过id获得新闻内容
		int cId = Integer.parseInt(request.getParameter("newsCatalogueId"));
		LeansnewsDaoImpl newsDao = new LeansnewsDaoImpl();		
		List<Leansnews> nList = newsDao.getLeansnewsList(cId);
		request.setAttribute("nList", nList);
		
		request.getRequestDispatcher("article_list(1).jsp").forward(request, response);		
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}

